{php include wl_template('common/header');}
<ul class="nav nav-tabs">
	<li ><a href="{php echo web_url('dashboard/banner/index')}">广告位</a></li>
	<li {if empty($banner['id'])}class="active"{/if}><a href="{php echo web_url('dashboard/banner/edit')}">添加广告</a></li>
	{if !empty($banner['id'])}
	<li class="active"><a href="#">编辑广告</a></li>
	{/if}
</ul>
<div class="app-content">
	<div class="app-form">
		<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" >
			<input type="hidden" name="id" value="{$banner['id']}" />
			<div class="panel panel-default">
				<div class="panel-heading">广告位设置</div>
				<div class="panel-body">
					<div class="form-group">
						<label class="col-sm-2 control-label">排序</label>
						<div class="col-sm-9">
							<input type="text" name="banner[displayorder]"  placeholder="默认排序为0" autocomplete="off" class="form-control" value="{$banner['displayorder']}">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">广告位标题<span class="must-fill">*</span></label>
						<div class="col-sm-9">
							<input type="text" name="banner[name]" required  autocomplete="off" class="form-control" value="{$banner['name']}">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">广告位图片<span class="must-fill">*</span></label>
						<div class="col-sm-9">
							{php echo attachment_select('banner[thumb]', $banner['thumb'])}
							<span class="help-block">建议图片大小为640*100，所有图片比例一样。</span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">广告位连接</label>
						<div class="col-sm-9">
							<div class="input-group form-group" style="margin: 0;">
								<input type="text" name="banner[link]"  class="form-control valid" readonly="readonly" placeholder="" id="advlink" value="{$banner['link']}">
								<span data-input="#advlink" data-toggle="selectUrl" class="input-group-addon btn btn-default">选择链接</span>
								<span class="input-group-addon btn btn-default clearinput">X</span>
							</div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">是否显示</label>
						<div class="col-sm-9">
							<div class="radio-inline">
								<input type="radio" name='enabled' value='1' {if $banner['enabled']==1}checked{/if}>是
							</div>
							<div class="radio-inline">
								<input type="radio" name='enabled' value='0' {if $banner['enabled']==0}checked{/if}>否
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"></label>
				<div class="col-sm-9">
					<input type="submit" name="submit" lay-submit value="提交" class="btn btn-primary min-width" />
					<input type="hidden" name="token" value="{$_W['token']}" />
				</div>
			</div>
		</form>
	</div>
</div>
<script>
	$('input[name="banner[thumb]"]').attr('required','required');
	myrequire(['layui'],function(){
		layui.use(['layer','form','laydate'], function(){
		  	var layer = layui.layer,
			form = layui.form();
		});
	});
	/**
	 * 点击删除图片或者链接
	 */
	$(".form").on('click','.clearinput',function () {
		$(this).prev().prev().val('');
	});
</script>
{php include wl_template('common/footer');}